<?php
    @include_once("conn.php");

    $sql = "select id,goodsId,goodsName,goodsImg,goodsPrice from `goodslist`";

    $result = mysqli_query($conn,$sql);

    $obj = array();
    if($result){

        $list = array();
         // 解析数据  => 赋值给变量 $item  =>  有数据,循环解析  没有数据(null) =>跳出循环
        while($item = mysqli_fetch_assoc($result)){
            // 预处理
            array_push($list,$item);
        }
        $obj["status"] = true;
        $obj["msg"] = "OK";
        $obj["list"] = $list;
    }else{
        $obj["status"] = false;
        $obj["msg"] = "sql语句有误";
        $obj["sql"] = $sql;
    }

    echo json_encode($obj);

?>